package com.ruoyi.web.controller.business;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HealthUserInfo;
import com.ruoyi.system.service.IHealthUserInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 提报人员信息Controller
 * 
 * @author ruoyi
 * @date 2020-02-21
 */
@Controller
@RequestMapping("/healthinfo/healthuserinfo")
public class HealthUserInfoController extends BaseController
{
    private String prefix = "healthinfo/healthuserinfo";

    @Autowired
    private IHealthUserInfoService healthUserInfoService;

    @RequiresPermissions("healthinfo:healthuserinfo:view")
    @GetMapping()
    public String healthuserinfo()
    {
        return prefix + "/healthuserinfo";
    }

    /**
     * 查询提报人员信息列表
     */
    @RequiresPermissions("healthinfo:healthuserinfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(HealthUserInfo healthUserInfo)
    {
        startPage();
        List<HealthUserInfo> list = healthUserInfoService.selectHealthUserInfoList(healthUserInfo);
        return getDataTable(list);
    }

    /**
     * 导出提报人员信息列表
     */
    @RequiresPermissions("healthinfo:healthuserinfo:export")
    @Log(title = "提报人员信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(HealthUserInfo healthUserInfo)
    {
        List<HealthUserInfo> list = healthUserInfoService.selectHealthUserInfoList(healthUserInfo);
        ExcelUtil<HealthUserInfo> util = new ExcelUtil<HealthUserInfo>(HealthUserInfo.class);
        return util.exportExcel(list, "healthuserinfo");
    }

    /**
     * 新增提报人员信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存提报人员信息
     */
    @RequiresPermissions("healthinfo:healthuserinfo:add")
    @Log(title = "提报人员信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(HealthUserInfo healthUserInfo)
    {
        return toAjax(healthUserInfoService.insertHealthUserInfo(healthUserInfo));
    }

    /**
     * 修改提报人员信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        HealthUserInfo healthUserInfo = healthUserInfoService.selectHealthUserInfoById(id);
        mmap.put("healthUserInfo", healthUserInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存提报人员信息
     */
    @RequiresPermissions("healthinfo:healthuserinfo:edit")
    @Log(title = "提报人员信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(HealthUserInfo healthUserInfo)
    {
        return toAjax(healthUserInfoService.updateHealthUserInfo(healthUserInfo));
    }
    

    /**
     * 删除提报人员信息
     */
    @RequiresPermissions("healthinfo:healthuserinfo:remove")
    @Log(title = "提报人员信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(healthUserInfoService.deleteHealthUserInfoByIds(ids));
    }
}
